﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.IO.IsolatedStorage;
using TED.Model;
using System.Xml.Linq;

namespace TED.ViewModels
{
    public class TEDVideoViewModel
    {
        public ObservableCollection<TEDVideo> TEDVideos { get; set; }

        public void GetTEDVideos()
        {
                GetDefaultTEDVideos();
        }

        public void GetDefaultTEDVideos()
        {
            ObservableCollection<TEDVideo> t = new ObservableCollection<TEDVideo>();

            // Items to collect
            t.Add(new TEDVideo
            {
                Title = "temp",
                Author = "temp",
                ViewUrl = "temp",
                ImageUrl = null,
                VideoUrl = null,
            });

            TEDVideos = t;
        }

        public void GetSavedTEDVideos()
        {
            ObservableCollection<TEDVideo> t = new ObservableCollection<TEDVideo>();

            foreach (Object o in IsolatedStorageSettings.ApplicationSettings.Values)
            {
                t.Add((TEDVideo)o);
            }

            TEDVideos = t;
            MessageBox.Show("Got TEDVideos from storage");
        }

        public void SetTEDVideos(ObservableCollection<TEDVideo> t)
        {
            TEDVideos = t;
        }

    }
}
